package com.charles.video.system.controller;

import com.charles.video.api.domain.MemberLog;
import com.charles.video.common.core.controller.BaseController;
import com.charles.video.common.core.responseDomain.AjaxResult;
import com.charles.video.common.core.responseDomain.R;
import com.charles.video.common.core.responseDomain.TableInfo;
import com.charles.video.common.log.annotation.Log;
import com.charles.video.system.mapper.MemberLogMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/member/log")
public class SysMemberLogController extends BaseController {

    @Autowired
    private MemberLogMapper memberLogMapper;

    @GetMapping("/getMemberLogList")
    public TableInfo getMemberLogList() {
        startPage();
        return getDataTable(memberLogMapper.queryMemberLogList());
    }

    @Log(behavior = "删除了系统日志")
    @DeleteMapping("/deleteMemberLog/{logId}")
    public AjaxResult deleteMemberLog(@PathVariable("logId") Long logId) {
        return toAjax(memberLogMapper.deleteMemberById(logId));
    }

    @PostMapping("/saveLog")
    public R<Boolean> saveLog(@RequestBody MemberLog memberLog) {
        return R.ok(memberLogMapper.saveMemberLog(memberLog));
    }

}
